package org.example.manage;


import org.example.model.Order;
import org.example.model.OrderItem;


public class OrderManage extends ObjectManage<Order> {

    public OrderManage(String fileName) {
        type = 2;
        setFileName(fileName);
    }
    @Override
    public boolean compare(Order item, Order uItem) {
        if (item.orderItems.size() != uItem.orderItems.size()) {
            return false;
        }
        for (int i = 0; i < item.orderItems.size(); i++) {
            OrderItem item1 = item.orderItems.get(i), item2 = uItem.orderItems.get(i);
            boolean b = item1.milkName.equals(item2.milkName) &&
                    item1.number == item2.number&&
                    item1.specification.equals(item2.specification) &&
                    item1.imagePath.equals(item2.imagePath) &&
                    item1.price == item2.price;
            if (!b) {
                return false;
            }
        }
        boolean b = item.mailbox.equals(uItem.mailbox) &&item.total == uItem.total&&
                item.totalPrice == uItem.totalPrice&&item.condition.equals(uItem.condition);
         return b;
    }
}
